package com.nbsaas.boot.common.rest.convert;

import com.nbsaas.boot.common.data.entity.Component;
import com.nbsaas.boot.common.api.domain.response.ComponentResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;
/**
* 实体对象转化成响应对象
*/

public class ComponentResponseConvert  implements Converter<ComponentResponse,Component> {

    @Override
    public ComponentResponse convert(Component source) {
        ComponentResponse  result = new  ComponentResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getType()!=null){
                    Map<Integer,String> TypeMap=new HashMap<>();
                        TypeMap.put(1,"系统");
                        TypeMap.put(2,"自定义");
                    String label=  TypeMap.get(source.getType());
                    result.setTypeName(label);
                    }
                    result.setType(source.getType());
        return result;
    }

}

